#! /bin/sh

VOLUME_1=/media/Win7
VOLUME_2=/media/Data

if [ ! -d $VOLUME_1 -o ! -d $VOLUME_2 ];
then
	echo "Error: source folder does not exist, please mount it first!" 1>&2
	exit 1
fi

export VOLUME_BACKUP=/media/Data_Backup_
export TRASH=$VOLUME_BACKUP/Trash
export TOP=`pwd`

if [ ! -d $TRASH ];
then
	mkdir -p $TRASH
fi

export forcedelete=false

tmpfile=/tmp/dirlist.log

iTunesDir=$VOLUME_1/Documents\ and\ Settings/cugfeng/Music/iTunes
MusicDir=$VOLUME_2/Music
TV_PlayDir=$VOLUME_2/TV_Play
MovieDir=$VOLUME_2/Movie
HomeDir=/home/cugfeng

echo $iTunesDir > $tmpfile
echo $MusicDir >> $tmpfile
echo $TV_PlayDir >> $tmpfile
echo $MovieDir >> $tmpfile
echo $HomeDir >> $tmpfile

cat $tmpfile | while read dir
do
	if [ -z "$dir" ];
	then
		continue
	fi

	if [ -e "$dir"/sync.sh ];
	then
		echo Sync dir: "$dir"
		export BASENAME=`basename "$dir"`
		cd "$dir"
		sh sync.sh
	fi
done

rm $tmpfile

